package com.jt.www.admin.stats.controller;

import com.jt.www.admin.stats.service.SchoolDutyService;
import com.jt.www.model.reps.ResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author admin_ltf
 * @create 2019-05-16 16:24
 */
@Api(value = "校责", tags = {"School-Duty-API"}, description = "校责")
@RestController
@RequestMapping(value = "/stats/scduty")
public class SchoolDutyController {

    public static final Logger log = LoggerFactory.getLogger(SchoolDutyController.class);


    @Autowired
    SchoolDutyService schoolDutyService;

    /**
     * 死亡事故类型占比
     *
     * @return
     */
    @ApiOperation(value = "死亡事故类型占比", notes = "死亡事故类型占比", httpMethod = "POST")
    @PostMapping(value = "/getAccidentType")
    public ResultDTO<Map<String, Object>> searchAccidentTypeInfo() {

        ResultDTO resultMap = schoolDutyService.searchAccidentTypeInfo();

        return resultMap;
    }

    /**
     * 死亡事故情况分布
     *
     * @return
     */
    @ApiOperation(value = "死亡事故情况分布", notes = "死亡事故情况分布", httpMethod = "POST")
    @PostMapping(value = "/getAccidentCondition")
    public ResultDTO<Map<String, Object>> searchAccidentCondition() {

        ResultDTO resultMap = schoolDutyService.searchAccidentCondition();

        return resultMap;
    }

    //    伤亡事故类型分布
    @ApiOperation(value = "伤亡事故类型分布-柱状图", notes = "伤亡事故类型分布-柱状图", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyType")
    public ResultDTO<Map<String, Object>> searchCasualtyType(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                             @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyType(startDate, endDate);

        return resultMap;
    }

    @ApiOperation(value = "伤亡事故类型分布-饼状图", notes = "伤亡事故类型分布-饼状图", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyTypePie")
    public ResultDTO<Map<String, Object>> searchCasualtyTypePie(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                                @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        //    ResultDTO resultMap = schoolDutyService.searchCasualtyTypePie(startDate,endDate);
        // 不确定  所以未做

        return null;
    }


    /**
     * 伤亡事故情况分布
     *
     * @param startDate
     * @param endDate
     * @return
     */
    @ApiOperation(value = "伤亡事故情况分布", notes = "伤亡事故情况分布", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyCondition")
    public ResultDTO<Map<String, Object>> searchCasualtyCondition(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                                  @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyCondition(startDate, endDate);

        return resultMap;
    }

    /**
     * 受伤类型情况分布
     *
     * @param startDate
     * @param endDate
     * @return
     */
    @ApiOperation(value = "受伤类型情况分布", notes = "受伤类型情况分布", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyTypeCondition")
    public ResultDTO<Map<String, Object>> searchCasualtyTypeCondition(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                                      @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyTypeCondition(startDate, endDate);

        return resultMap;
    }


    @ApiOperation(value = "伤亡事故原因分布", notes = "伤亡事故原因分布", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyReason")
    public ResultDTO<Map<String, Object>> searchCasualtyReason(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                               @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyReason(startDate, endDate);

        return resultMap;
    }

    @ApiOperation(value = "伤亡事故场所分布", notes = "伤亡事故场所分布", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyLocation")
    public ResultDTO<Map<String, Object>> searchCasualtyLocation(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                                 @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyLocation(startDate, endDate);

        return resultMap;
    }


    @ApiOperation(value = "伤亡事故出险时间段分布", notes = "伤亡事故出险时间段分布", httpMethod = "GET")
    @GetMapping(value = "/getCasualtyDuration")
    public ResultDTO<Map<String, Object>> searchCasualtyDuration(@ApiParam(value = "出险起期", required = false) @RequestParam(value = "startDate", required = false) String startDate,
                                                                 @ApiParam(value = "出险止期", required = false) @RequestParam(value = "endDate", required = false) String endDate) {

        ResultDTO resultMap = schoolDutyService.searchCasualtyDuration(startDate, endDate);

        return resultMap;
    }
}
